package com.only4play.portal.cp.bean.outbuilder.outjsonbuilder;

import com.only4play.portal.cp.bean.message.jsonmessage.CpJsonOutMessage;
import com.only4play.portal.cp.bean.outbuilder.AbstractBuilder;

public abstract class JsonBaseBuilder<BuilderType, ValueType> extends AbstractBuilder<BuilderType, ValueType> {
    protected String fromUserName;

    protected String toUserName;

    public BuilderType toUser(String toUserName) {
        this.toUserName = toUserName;
        return (BuilderType) this;
    }

    public BuilderType fromUser(String fromUserName) {
        this.fromUserName = fromUserName;
        return (BuilderType) this;
    }

    public abstract ValueType build();

    public void setCommon(CpJsonOutMessage m) {
        m.setToUserName(this.toUserName);
        m.setFromUserName(this.fromUserName);
        m.setCreatedAt(System.currentTimeMillis() / 1000L);
    }
}
